//
//  ThirdHomeViewController.m
//  225视听百科
//
//  Created by 张潇 on 14/12/29.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "ThirdHomeViewController.h"
#import "SettingViewController.h"
#import "MainViewController.h"
#import "CollectViewController.h"
#import "ThirdHomeTableCell.h"
@interface ThirdHomeViewController ()

@end

@implementation ThirdHomeViewController


- (void)dealloc
{
    [_bigTable release];
    [_thirdHomeArray release];
    [super dealloc];
}


-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.thirdHomeArray = [NSMutableArray array];
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    UIView *white = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:white];
    [self createView];
}


-(void)createView
{
    
    self.tabBarController.tabBar.hidden = YES;
    
    self.bigTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [_bigTable registerClass:[ThirdHomeTableCell class] forCellReuseIdentifier:@"thirdHomeCell"];
    
    _bigTable.delegate = self;
    _bigTable.dataSource = self;
    [self.view addSubview:_bigTable];
    [_bigTable release];
    
    UIImageView *header = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height / 4)];
    header.image = [UIImage imageNamed:@"thirdhomeback.png"];
    _bigTable.tableHeaderView = header;
    
    
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = CGRectMake(0, 0, 25, 25);
    [rightButton setBackgroundImage:[UIImage imageNamed:@"setting.png"] forState:UIControlStateNormal];
    [rightButton addTarget:self action:@selector(settingAction:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    
    
    UIView *downView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 125, self.view.frame.size.width, 55)];
    downView.backgroundColor = [UIColor blackColor];
    downView.alpha = 0.9;
    [self.view addSubview:downView];
    [self.view bringSubviewToFront:downView];
    
    
    
    UIButton *returnButton = [UIButton buttonWithType:UIButtonTypeCustom];
    returnButton.frame = CGRectMake(20, 10, 30, 30);
    [returnButton setBackgroundImage:[UIImage imageNamed:@"return.png"] forState:UIControlStateNormal];
    [returnButton addTarget:self action:@selector(ReturnAction:) forControlEvents:UIControlEventTouchUpInside];
    [downView addSubview:returnButton];
    
    
    UIButton *homeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    homeButton.frame = CGRectMake(self.view.frame.size.width / 3, 10, 30, 30);
    [homeButton setBackgroundImage:[UIImage imageNamed:@"home.png"] forState:UIControlStateNormal];
    [homeButton addTarget:self action:@selector(HomeAction:) forControlEvents:UIControlEventTouchUpInside];
    [downView addSubview:homeButton];
    
    
    UIButton *collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
    collectButton.frame = CGRectMake(self.view.frame.size.width *2 / 3, 10, 30, 30);
    [collectButton setBackgroundImage:[UIImage imageNamed:@"collect.png"] forState:UIControlStateNormal];
    [collectButton addTarget:self action:@selector(collectAction:) forControlEvents:UIControlEventTouchUpInside];
    [downView addSubview:collectButton];
    
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 20;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ThirdHomeTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"thirdHomeCell"];
    
    return cell;
}



-(void)ReturnAction:(id)sender
{
    self.tabBarController.tabBar.hidden = NO;
    [self.navigationController popViewControllerAnimated:YES];
    
}


-(void)HomeAction:(id)sender
{
    MainViewController *home = [[MainViewController alloc] init];
    self.tabBarController.tabBar.hidden = NO;
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    
    [home release];
}


-(void)collectAction:(id)sender
{
    CollectViewController *collect = [[CollectViewController alloc] init];
    
    [self.navigationController pushViewController:collect animated:YES];
    
    [collect release];
}


-(void)settingAction:(id)sender
{
    
    SettingViewController *setting = [[SettingViewController alloc] init];
    
    [self.navigationController pushViewController:setting animated:YES];
    
    [setting release];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
